(* test/test_lexer.ml *)
open Toyc.Lexer
open Toyc.Token


let print_tokens lexbuf =
  let rec loop () =
    match token lexbuf with
    | EOF -> print_endline "EOF"; ()
    | tok -> 
        print_endline (to_string tok);
        loop ()
  in
  loop ()

let () =
  let input_file = "test/test_input.toyc" in  (* 使用相对路径 *)
  let ic = open_in input_file in
  let lexbuf = Lexing.from_channel ic in
  print_tokens lexbuf;
  close_in ic
  (*let input_file = open_in "test_input.toyc" in
  let lexbuf = Lexing.from_channel input_file in
  print_tokens lexbuf;
  close_in input_file*)